package de.mhus.lib.mandala.form;

import de.mhus.lib.mandala.Response;

public class RadioSelect extends Select {

	public RadioSelect(String id, String caption, String ... valuecaption) {
		super(id, caption, valuecaption);
	}

	@Override
	protected void doRenderEdit(Response out) {
		for (Option option : options) {
			out.startTag("div", "radio", null);
			out.startTag("label", null, null);
			out.startTag("input", null, null, "type", "radio", "name", getId(), "id", getId() + "_" + option.getValue(), "value", option.getValue() );
			out.endTag("input");
			out.printEncoded(option.getCaption());
			out.endTag("label");
			out.endTag("div");
		}
	}

	@Override
	protected void doRenderView(Response out) {
		for (Option option : options) {
			out.startTag("div", "radio", null);
			out.startTag("label", null, null);
			out.startTag("input", null, null, "type", "radio", "name", getId(), "id", getId() + "_" + option.getValue(), "value", option.getValue(), "disabled", "disabled" );
			out.endTag("input");
			out.printEncoded(option.getCaption());
			out.endTag("label");
			out.endTag("div");
		}
	}

}
